package com.caesar.Abnormal;

/**
 * @author caesar
 * @date 2025/7/14
 * @Description:
 * @apiNote
 */
public class GraphicTools {
    public static void printDiamond(int line,char sign)throws Exception{
        if(line<3 || line%2==0){
            throw new Exception("菱形的行数必须是大于等于3的奇数");
        }
        //上半部分：正的等腰三角形
        for(int i=1; i<=line/2+1; i++){
            for(int j=line/2; j>=i; j--){
                System.out.print("  ");
            }
            for(int j=1; j<=2*i-1; j++){
                System.out.print(sign);
            }
            System.out.println();
        }

        //下半部分：倒立的等腰三角形
        for(int i=1; i<=line/2; i++){
            for(int j=1; j<=i; j++){
                System.out.print("  ");
            }
            for(int j=1; j<=line-2*i; j++){
                System.out.print(sign);
            }
            System.out.println();
        }
    }
}
